<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
    <caption>员工列表</caption>
    <tr>
        <th>id</th>
        <th>名字</th>
        <th>工资</th>
        <th>工作</th>
    </tr>
</table>

<script src="../day06/jq.js"></script>
<script>
    let arr =[
        {id:1,name:"张三",salary:5000,job:"销售"},
        {id:2,name:"李四",salary:6000,job:"程序员"},
        {id:3,name:"王五",salary:2000,job:"市场"}
    ]
//    遍历数组，创建tr 创建td  把给td设置显示内容，把td装进tr,把tr装进table
    for (let i = 0; i <arr.length ; i++) {
        // 创建tr和td
        let tr=$("<tr></tr>");
        let idtd=$("<td></td>");
        let nametd=$("<td></td>");
        let salarytd=$("<td></td>");
        let jobtd=$("<td></td>");
        // 取出员工对象
        let map=arr[i];
        // td设置显示文本
        idtd.text(map.id);
        nametd.text(map.name);
        salarytd.text(map.salary);
        jobtd.text(map.job);
        // 把td装入tr
        tr.append(idtd);
        tr.append(nametd);
        tr.append(salarytd);
        tr.append(jobtd);

        $("table").append(tr);

    }
</script>

</body>
</html>